var _util = require('../util/util.js')

var _cart_service = {
  getCartData: function (userId, resolve, reject) {
    _util.request({
      url: _util.getServerURL('cart') + `?userId=${userId}`,
      method: 'GET',
      success: resolve,
      error: reject
    });
  },
  removeItem: function (userId, itemId, resolve, reject) {
    _util.request({
      url: _util.getServerURL(`removeItem/${itemId}?userId=${userId}`),
      method: 'POST',
      success: resolve,
      error: reject,
    });
  },
  updateCart: function (userId, itemId, count, resolve, reject) {
    _util.request({
      url: _util.getServerURL(`updateCart/${itemId}/${count}?userId=${userId}`),
      method: 'POST',
      success: resolve,
      error: reject,
    });
  },
}

module.exports = _cart_service;